using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AvaVSExt.Helpers
{
    public static class FileSystemHelper
    {
        public static IEnumerable<string> GetFiles(string path, string pattern)
        {
            var list = new List<string>();
            GetFiles(path, pattern, ref list);
            return list;
        }

        private static void GetFiles(string path, string pattern, ref List<string> list)
        {
            foreach (var subdir in Directory.GetDirectories(path))
            {
                var name = Path.GetFileName(subdir);
                if (char.IsUpper(name[0]) == false) continue;
                GetFiles(subdir, pattern, ref list);
            }

            var files = Directory.GetFiles(path, pattern, SearchOption.TopDirectoryOnly);
            if (files.Length != 0)
                list.AddRange(files);

        }

    }
}
